package org.jash.day2

/**
 * Created by Jash
 */
fun main() {
    val str = "zhangsan 12, lisi 14, wangwu 16"
    val split = str.split(", ")
    val users = mutableListOf<User>()
    for (s in split) {
        val u = s.split(" ")
        users += User(u[0], u[1].toInt())
    }
    println(users)
//    users.removeIf({ "wang" in it.name })
//    println(users)
    var sum = 0
    for (u in users) {
        sum += u.age
    }
    println(sum / users.size)
    var maxUser = users[0]
    for (u in users) {
        if (u.age > maxUser.age) {
            maxUser = u
        }
    }
    println(maxUser)
}